<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <script>
        // //扩展运算符可以吧数组拆分成以逗号分割的参数序列
        // let arr = ['a', 'b', 'c'];
        // // ...arr = 'a','b','c'
        // console.log(...arr);
        // console.log('a', 'b', 'c');


        //扩展运算符用于数组合并
        // let arr1 = [1, 2, 3];
        // let arr2 = [4, 5, 6];
        // let arr3 = [...arr1, ...arr2];
        // console.log(arr3);
        // console.log(...arr3);

        //合并数组的第二种方法 
        // let arr1 = [1, 2, 3];
        // let arr2 = [4, 5, 6];
        // arr1.push(...arr2);
        // arr1.unshift(0, -1);
        // console.log(arr1);

        //通过扩展运算符把伪数组转变为真正的数组
        // var divs = document.querySelectorAll('div')
        // console.log(divs);
        // divs = [...divs];
        // divs.push('a')
        // console.log(divs);

        //另一种方法转换伪数组Array.from
        var obj = {
            0: 1,
            1: 2,
            2: 3,
            length: 3
        }
        console.log(obj);
        var arr = Array.from(obj, item => item * 2)
        console.log(arr);
    </script>
</body>

</html>